package com.test.io.buffer;

import org.junit.Test;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @version 1.0
 * @Author: 许啸林 使用处理流输出字符
 * @Date: 2021/6/2 16:18
 */
public class BufferedWriterDemo {
    @Test
    public void writeFile() {
        BufferedWriter bufferedWriter = null;
        try {
            bufferedWriter = new BufferedWriter(new FileWriter("d:\\bfWriter.text"));
            bufferedWriter.write("Hello, world");
            bufferedWriter.newLine();
            bufferedWriter.write("Hello, world");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(bufferedWriter != null){
                try {
                    bufferedWriter.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }
    }
}
